<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 * @author   howe <howe1995@163.com>
 */
use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

return new class() extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('moment_messages', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('from_user')->default(0)->comment('来自用户ID');
            $table->unsignedBigInteger('to_user')->default(0)->comment('回复用户ID');
            $table->unsignedBigInteger('moment_id')->default(0)->comment('朋友圈ID');
            $table->enum('type', ['like', 'comment'])->default('like')->comment('类型(like=点赞,comment=评论)');
            $table->string('content', 1000)->default('')->comment('回复内容');
            $table->timestamp('created_at')->useCurrent()->comment('创建时间');
            $table->timestamp('deleted_at')->nullable()->default(null)->comment('删除时间');
            $table->index(['moment_id'], 'idx_moment_id', 'BTREE');
            $table->index(['from_user'], 'idx_from_user', 'BTREE');
            $table->index(['to_user'], 'idx_to_user', 'BTREE');
            $table->comment('朋友圈消息');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('moment_messages');
    }
};
